package com.alstudio.ui.module.image.browser;

import java.util.ArrayList;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageSwitcher;

import com.alstudio.R;
import com.alstudio.pojo.module.image.AlPhoto;
import com.alstudio.ui.base.TitleBarActivity;

public class ImageViewerActivity extends TitleBarActivity {

	private final String TAG = "ImageViewerActivity";

	private static boolean isResetPhotoRequired;
	private String imagePath;
	private ArrayList<AlPhoto> photos;
	private ImagePagerAdapter mImagePageradapter;

	private ViewPager mPagedView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setupView(this, TAG);
		initData();
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
//		mImagePageradapter = new ImagePagerAdapter(getSupportFragmentManager(),
//				500);
//		mPagedView.setAdapter(mImagePageradapter);
	}

	@Override
	protected void setupView(Context context, String name) {
		// TODO Auto-generated method stub
		super.setupView(context, name);
		setTitleBarContentView(R.layout.photos_viewer_layout);
		mPagedView = (ViewPager) findViewById(R.id.view_pager);
	}

	/**
	 * The main adapter that backs the ViewPager. A subclass of
	 * FragmentStatePagerAdapter as there could be a large number of items in
	 * the ViewPager and we don't want to retain them all in memory at once but
	 * create/destroy them on the fly.
	 */
	private class ImagePagerAdapter extends FragmentStatePagerAdapter {
		private final int mSize;

		public ImagePagerAdapter(FragmentManager fm, int size) {
			super(fm);
			mSize = size;
		}

		@Override
		public int getCount() {
			return mSize;
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			// TODO Auto-generated method stub
			super.destroyItem(container, position, object);

			// if (position < photos.size() && position != 0) {
			// if (position != 0) {
			// Mylog.e("位置为 " + position + " 的图片已被销毁");
			// }
			// }

		}

		@Override
		public Fragment getItem(int position) {

			// String fileId = photos.get(position).getPicFileid();
			// Mylog.d("fileid " + fileId);
			return ImageDetailFragment.newInstance(null);
			// return null;
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

}
